package br.com.faces.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

public class FacesUtil {
	
	public static HttpSession getSession(){
	FacesContext fc = FacesContext.getCurrentInstance();
	HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);
	return session;
	}
	
	public static Calendar transformaData(Date data){
		
		Calendar cal = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		String mostra = sdf.format(data);
		System.out.println(mostra);
		try{
			
			Calendar calendar = Calendar.getInstance(); 
			calendar.setTime(data); 
			String mostr = sdf.format(calendar.getTime());
			System.out.println(mostr);
		}catch(Exception ex){
			ex.printStackTrace();
		}
		return cal;
	}
	
}
